const Utils = require("./Utils.js")

Utils.init()

let flag, swipeType

flag = true
swipeType = "up"

const fight = () => {
  if (Utils.findPictureTap("准备")) {
    
    while (!Utils.findPictureTap("奖励")) {
      if (Utils.findPictureTap("胜利")) {
        
      }
    }
  }
}

while (flag) {
	sleep(1000)
  if (Utils.findPictureTap("自动匹配")) {
    fight()
  } else if (Utils.findPictureTap("年兽")) {
		log("成功")
	} else {
		if (swipeType === "up") {
			if (Utils.findPictureTap("契灵之境", 0.8)) {
				log("滑到底了")
				swipeType = "down"
			} else {
				// 向上滑动
				swipe(random(230, 540), 850, random(230, 540), 300, 2000)
			}
		}
		if (swipeType === "down") {
			if (Utils.findPictureTap("全部", 0.8)) {
				log("滑到顶了")
				swipeType = "up"
			} else {
				// 向下滑动
				swipe(random(230, 540), 300, random(230, 540), 850, 2000)
			}
		}
  }
  
}
